import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);

//一级组件
import DashBoard from './../views/dashboart/DashBoard.vue'

//二级组件--懒加载
const Home = () => import('./../views/home/Home.vue');
const Category = () => import('./../views/category/Category.vue');
const Cart = () => import('./../views/cart/Cart.vue');

//用户中心
const Mine = () => import('./../views/mine/Mine.vue');
const UserCenter = () => import('./../views/mine/children/UserCenter.vue')

// 引入结算组件相关
const Order = () => import('./../views/order/Order.vue');
const MyAddress = () => import('./../views/order/children/MyAddress.vue');
const EditAddress = () => import('./../views/order/children/children/EditAddress.vue');
const AddAddress = () => import('./../views/order/children/children/AddAddress.vue');


// 引入登陆
const Login = () => import('./../views/login/Login.vue')


export default new Router({
  routes: [
    { path: '/', redirect: '/dashboard' },
    {
      path: '/dashboard',
      name: 'dashboard',
      component: DashBoard,
      children: [
        { path: '/dashboard', redirect: '/dashboard/home' },
        { path: 'home', name: 'home', component: Home, meta: { keepAlive: true } },
        { path: 'category', name: 'category', component: Category, meta: { keepAlive: true } },
        { path: 'cart', name: 'cart', component: Cart },
        { 
          path: 'mine', 
          name: 'mine', 
          component: Mine,
          children:[
            {path:'usercenter', component:UserCenter} // 用户中心
          ]
        }
      ]

    },
    {
      path: '/confirmOrder',
      name: 'order',
      component: Order,
      children: [
        {
          path: 'myAddress',
          name: 'myAddress',
          component: MyAddress,
          children: [
            { path: 'editAddress', name: 'editAddress', component: EditAddress },
            { path: 'addAddress', name: 'addAddress', component: AddAddress }
          ]
        }
      ]
    },
    { path: '/login', name: 'login', component: Login }
  ]


})